package com.qutan.app.core.common;

import org.slf4j.Logger;
import org.springframework.ui.Model;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by pwy on 16/5/15
 * web 的 doing
 */
public interface WDoing<T> extends BaseDoing<T> {

    /**
     * 包装web 请求
     * @param r HttpServletRequest
     * @param m Model
     * @param log Logger
     * @return
     */
    default ViewData go(HttpServletRequest r, Model m, Logger log) {
        ViewData viewData = new ViewData();
        try {
            this.showParams(r, log);
            this.service(r, m, viewData);
        } catch (Exception e) {
            this.errorLog(log, e, viewData);
        }
        return viewData;
    }


    void service(HttpServletRequest r, Model m, ViewData vd) throws Exception;

}
